import ddt
from testconfig import config

from framework.appium.appiumbasetest import AppiumBaseTest
from lib.mobile.mobiletasks import MobileTasks


@ddt.ddt()
class MobileTest(AppiumBaseTest):

    _multiprocess_can_split_ = True

    def setUp(self):
        super().setUp(config=config)

    def tearDown(self):
        super().tearDown()

    @ddt.data('SamSung1', 'android')
    def android_automation_test(self, device_name):
        self.init_driver_by_device_name(config, deviceName=device_name)
        self.mobile_tasks = MobileTasks(self.driver)

        ret = self.mobile_tasks.is_record_event_btn_exist()
        self.logger.info(f'RecordEven按钮元素可以在页面上被定位到 => {ret}')
        self.assertTrue(ret, 'RecordEven按钮元素无法被定位！！')

    @ddt.data('SamSung2')
    def android_failure_test(self, device_name):
        self.init_driver_by_device_name(config, deviceName=device_name)
        self.assertTrue(False, '测试用例，故意失败；测试失败截图功能！')

    @ddt.data('iPhoneXS', 'ios')
    def ios_automation_test(self, device_name):
        self.init_driver_by_device_name(config, deviceName=device_name)
        self.mobile_tasks = MobileTasks(self.driver)
        self.mobile_tasks.click_next_btn()
        ret = self.mobile_tasks.is_ctn_btn_exist()
        self.logger.info(f'Continue按钮存在 => {ret}')
        self.assertTrue(ret, f'Continue按钮不存在')
